package com.hui.xiao.xiaohui.view;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.SimpleAdapter;
import android.widget.StackView;

import com.hui.xiao.xiaohui.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/20.
 */
public class StackViewTest extends Activity {
    StackView stackView;
    int[] images = new int[]{
            R.drawable.aboc, R.drawable.bkch, R.drawable.logo,
            R.drawable.aboc, R.drawable.bkch, R.drawable.logo,
            R.drawable.aboc, R.drawable.bkch, R.drawable.logo
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.stack_view);
        stackView = (StackView) findViewById(R.id.stackView);
        List<Map<String, Object>> items = new ArrayList<>();
        for (int i = 0; i < images.length; i++) {
            Map<String, Object> item = new HashMap<>();
            item.put("image", images[i]);
            items.add(item);
        }
        SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.cell, new String[]{"image"}, new int[]{R.id.image1});
        stackView.setAdapter(adapter);
    }

    public void prev(View view) {
        stackView.showPrevious();
    }

    public void next(View view) {
        stackView.showNext();
    }
}
